﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using DTO_HealthInsurance;


namespace DAO_HealthInsurance
{
   public class DAOAdminLogin:ConnectDatabase
   {
       public SqlCommand Cmd;
       public  DTOAdminLogin objAdmin;

       //Constructor Check Login for Admin
        public bool AdminLogin(DTOAdminLogin objAdmin) {
            try
            {   
                OpenConnect();
                Cmd = new SqlCommand("CheckAdminLogin",Conn);
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.Parameters.Add("@UserName",SqlDbType.VarChar,50).Value = objAdmin.UserName;
                Cmd.Parameters.Add("@PassWord",SqlDbType.VarChar,50).Value= objAdmin.Password;
                SqlDataReader dr = Cmd.ExecuteReader();
              
                if (dr.HasRows)
                {
                    return true;
                }
                return false;
            }

            catch (Exception ex)
            {
              throw ex;
            }
            CloseConnect();
        }
       // Constructor Change Password for Admin
        public int AdminChangePass(DTOAdminLogin objAdmin)
        {
            int Result = 0;
            try
            {
                OpenConnect();
                Cmd = new SqlCommand("ChangePassAdmin", Conn);
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.Parameters.Add("@UserName", SqlDbType.VarChar, 50).Value = objAdmin.UserName;
                Cmd.Parameters.Add("@PassWord", SqlDbType.VarChar, 50).Value = objAdmin.Password;
                Result = Cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return Result;
        }
      
       
    }
}
